package com.itheima.d1_Map_impl;

import java.util.*;
import java.util.function.BiConsumer;

/**
 * 集合的嵌套
 */
public class Test {
    public static void main(String[] args) {
        Map<String, List<String>> map = new HashMap<>();

        List<String> selects1 = new ArrayList<>();
        Collections.addAll(selects1,"A","C");
        map.put("顶针",selects1);
        List<String> selects2 = new ArrayList<>();
        Collections.addAll(selects2,"B","D");
        map.put("找找",selects2);
        List<String> selects3 = new ArrayList<>();
        Collections.addAll(selects3,"B","A");
        map.put("黄小米叔叔",selects3);

        System.out.println(map);

        //统计每个景点的人数
        Map<String,Integer> info = new HashMap<>();
        map.forEach((String s, List<String> strings) -> {
                for (String string : strings) {
                    if(info.containsKey(string)){
                        info.put(string,info.get(string)+1);
                    }
                    else info.put(string,1);
                }

            }
        );
        System.out.println(info);
    }
}
